package com.gaohe.controller;

import com.gaohe.common.Result;
import com.gaohe.pojo.Admin;
import com.gaohe.service.AdminService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    /**
     * 登录
     * @param request 请求对象
     * @param admin 接收用户输入的用户名和密码
     * @return
     */
    @PostMapping("/login")
    public Result login(HttpServletRequest request,@RequestBody Admin admin) {
        return adminService.login(request,admin);
    }

    /**
     * 退出登录
     * @param request 请求对象
     * @return
     */
    @GetMapping("/logout")
    public Result logout(HttpServletRequest request){
        return adminService.logout(request);
    }

}
